#ifndef __PID_H
#define __PID_H

#include "main.h"

// 0---陀螺仪闭环    1---编码器闭环
#define YUNTAIMODE 0
class PID
{
public:
    float kp, ki, kd;                     // 三个系数
    float error, lastError, prev_error;   // 误差、上次误差、上上次误差
    float integral, maxIntegral;          // 积分、积分限幅(该项是公共的)
    float output, output_prev, output_rate, maxOutput; // 输出、输出限幅
    float reference, feedback;            // 目标值、实际值
    float dout;
    float pout;
    float iout;

    // 电机的方向
    int8_t Dir;

    PID(float p, float i, float d, float maxi, float maxout);
    PID(/* args */) {}
    ~PID() {}
    void PosPIDCalc(float output_ramp);
    void DelPIDCalc(void);
};
#if (YUNTAIMODE == 0)
extern PID Pitch_W_PID;
extern PID Pitch_Angle_PID;
extern PID Fire_LM_PID;
extern PID Fire_RM_PID;
#endif
#if (YUNTAIMODE == 1)
extern PID Pitch_Pos_PID;
#endif

#endif
